<!-- start header -->

<header>
	<div class="top center">
		<div class="left fl">
			<ul>
				<li><a href="../pages/index.html">小米商城</a></li>
				<li>|</li>
				<li><a href="#">MIUI</a></li>
				<li>|</li>
				<li><a href="#">loT</a></li>
				<li>|</li>
				<li><a href="#">云服务</a></li>
				<li>|</li>
				<li><a href="#">金融</a></li>
				<li>|</li>
				<li><a href="#">有品</a></li>
				<li>|</li>
				<li><a href="#">小爱开放平台</a></li>
				<li>|</li>
				<li><a href="#">企业团购</a></li>
				<li>|</li>
				<li><a href="#">资质证照</a></li>
				<li>|</li>
				<li><a href="#">协议规则</a></li>
				<li>|</li>
				<li><a href="#">下载app</a></li>
				<li>|</li>
				<li><a href="#">Select Location</a></li>
				<div class="clear"></div>
			</ul>
		</div>
		<div class="right fr">
			<div class="gouwuche fr" id="addCart">
				<svg width="1em" height="1em" viewBox="0 0 16 16" class="bi bi-cart3" fill="currentColor"
					xmlns="http://www.w3.org/2000/svg">
					<path fill-rule="evenodd"
						d="M0 1.5A.5.5 0 0 1 .5 1H2a.5.5 0 0 1 .485.379L2.89 3H14.5a.5.5 0 0 1 .49.598l-1 5a.5.5 0 0 1-.465.401l-9.397.472L4.415 11H13a.5.5 0 0 1 0 1H4a.5.5 0 0 1-.491-.408L2.01 3.607 1.61 2H.5a.5.5 0 0 1-.5-.5zM3.102 4l.84 4.479 9.144-.459L13.89 4H3.102zM5 12a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm7 0a2 2 0 1 0 0 4 2 2 0 0 0 0-4zm-7 1a1 1 0 1 0 0 2 1 1 0 0 0 0-2zm7 0a1 1 0 1 0 0 2 1 1 0 0 0 0-2z" />
				</svg>
				<a >购物车<span id="shopCarNum"></span></a>
			</div>
			<div class="fr" id="userLog">
				<ul>
					<li><a href="../pages/login.html">登录</a></li>
					<li>|</li>
					<li><a href="../pages/register.html">注册</a></li>
					<li>|</li>
					<li><a href="">消息通知</a></li>
				</ul>
			</div>
			<div class="clear"></div>
		</div>
		<div class="clear"></div>
	</div>
</header>
<script src="../lib/jquery.js"></script>
<script src="../lib/jquery.cookie.js"></script>
<script src="../lib/template-web.js"></script>
	<script type="text/template" id="user">
		{{if user.name}}
			<ul>
				<li>{{user.name}} <span class="caret"></span></a></li>
				<li>|</li>
				<li><a href="">消息通知</a></li>
				<li>|</li>
				<li><a href="">我的订单</a></li>
			</ul>
		{{else}}
			<ul>
				<li><a href="../pages/login.html">登录</a></li>
				<li>|</li>
				<li><a href="../pages/register.html">注册</a></li>
				<li>|</li>
				<li><a href="">消息通知</a></li>
			</ul>
		{{/if}}
</script>
	<script>
		var cookieArr = $.cookie();
		var html = template('user', {
			user: {
				name: cookieArr['uname']
			}
		});
		$('#userLog').html(html);

		$('#addCart').click(function(){
			var username=cookieArr['uname'];
			console.log(username);
			if(username){
				$(location).attr('href', '../pages/shopCar.html?username='+username);
			}else{
				$(location).attr('href', '../pages/login.html');
			}
		})
	</script>


